{% extends 'rbac/base.html' %}
{% block addcss %}
    <link href="/static/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <style>
        .font-size-16 {
            font-size: 16px;
        }

        .border_color {
            border-left: solid #ff911e 4px;
            background-color: #ECECEC;

        }

        .i-default {
            font-size: 15px;
            display: inline-block;
            color: #676a6c;
        }

        .add-btn-a {
            padding: 2px 8px;
            margin: -3px;
            color: #fff !important;
        }
    </style>
{% endblock %}
{% block content %}
    {% load menu %}
    {% breadcrumb request %}
    <div class="wrapper wrapper-content animated fadeIn">
    {% csrf_token %}
        <div class="row">
            <div class="col-lg-3">
                <div class="ibox">
                    <div class="ibox-title">
                        <h5><i class="fa fa-th-large "></i>&nbsp;&nbsp;一级菜单</h5>

                        <div class="ibox-tools">
                            <a href="{% url 'rbac:menu_add' %}" class="right btn btn-primary btn-xs">
                                <i class="fa fa-plus-circle" aria-hidden="true"></i> 新建
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content" style="">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>图标</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for menu in menus %}
                                <tr class="{% if menu.id == menu_id %}border_color{% endif %}">
                                    <td><a href="?mid={{ menu.id }}">{{ menu.title }}</a></td>
                                    <td style="font-size: 16px">{{ menu.icon.tag|safe }}</td>
                                    <td class="">
                                        <a href="{% url 'rbac:menu_edit' pk=menu.id %}"
                                           class="text-info font-size-16"><i class="fa fa-edit"></i></a>
                                        <a href="#" id="{{ menu.id }}" del-url="{% url 'rbac:menu_del' pk=menu.id %}"
                                           class="text-danger font-size-16 a-del"><i
                                                class="fa fa-trash-o"></i></a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <div class="col-lg-4">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5><i class="fa fa-book"></i>&nbsp;&nbsp;二级菜单</h5>
                        <div class="ibox-tools">
                            {% if menu_id %}
                                <a href="{% memory_url request 'rbac:second_menu_add' menu_id=menu_id %}"
                                   class="right btn btn-primary btn-xs"
                                   style="padding: 2px 8px;margin: -3px;">
                                    <i class="fa fa-plus-circle" aria-hidden="true"></i>
                                    新建
                                </a>
                            {% endif %}
                        </div>
                    </div>
                    <div class="ibox-content">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>CODE & URL</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for row in second_menus %}
                                <tr class="{% if row.id|safe == second_menu_id %}border_color{% endif %}">
                                    <td rowspan="2"><a href="?mid={{ menu_id }}&sid={{ row.id }}">{{ row.title }}</a>
                                    </td>
                                    <td style="font-size: 16px">{{ row.name }}</td>
                                    <td>
                                        <a href="{% memory_url request 'rbac:second_menu_edit' pk=row.id %}"
                                           class="text-info font-size-16"><i class="fa fa-edit"></i></a>

                                        <a href="#"
                                           class="text-danger font-size-16 a-del" id="{{ row.id }}"
                                           del-url="{% url 'rbac:second_menu_del' pk=row.id %}">
                                            <i class="fa fa-trash-o"></i>
                                        </a>
                                    </td>
                                </tr>
                                <tr class="{% if row.id|safe == second_menu_id %}border_color {% endif %}">
                                    <td colspan="2" style="border-top: 0">{{ row.url }}</td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
            <div class="col-lg-5">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5><i class="fa fa-rebel"></i>&nbsp;&nbsp;权限菜单</h5>
                        <div class="ibox-tools">
                            {% if second_menu_id %}
                                <a href="{% memory_url request 'rbac:permission_add' second_menu_id=second_menu_id %}"
                                   class="right btn btn-primary btn-xs"
                                   style="padding: 2px 8px;margin: -3px;">
                                    <i class="fa fa-plus-circle" aria-hidden="true"></i>
                                    新建
                                </a>
                            {% endif %}
                            <a href="{% memory_url request 'rbac:multi_permissions' %}" class="btn btn-xs btn-success"
                               style="padding: 2px 8px;margin: -3px 0;color: white !important;">
                                <i class="fa fa-mail-forward" aria-hidden="true"></i>
                                批量操作
                            </a>

                        </div>
                    </div>
                    <div class="ibox-content no-padding">
                        <table class="table table-hover">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>CODE & URL</th>
                                <th>选项</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for row in permissions %}
                                <tr>
                                    <td rowspan="2">{{ row.title }}</td>
                                    <td style="font-size: 16px">{{ row.name }}</td>
                                    <td>
                                        <a href="{% memory_url request 'rbac:permission_edit' pk=row.id %}"
                                           class="text-info font-size-16"><i class="fa fa-edit"></i></a>

                                        <a del-url="{% url  'rbac:permission_del' pk=row.id %}" id="{{ row.id }}" href="#"
                                           class="text-danger font-size-16 a-del"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="border-top: 0;">{{ row.url }}</td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>

        </div>
    </div>
{% endblock %}

{% block addjs %}
    <script src="/static/js/plugins/sweetalert/sweetalert.min.js"></script>
    <script src="/static/rbac/del.js"></script>
{% endblock %}